<layout name='Layout/layout_main' />
<script type="text/javascript" src="__PUBLIC__/editor/kindeditor.js"></script>
<script type="text/javascript" src="__PUBLIC__/editor/kindeditor.setting.js"></script>
<script type="text/javascript">
function send(flag){
$("#to").val("");
$("#recever .address_list span").each(function() {
$("#to").val($("#to").val() + $(this).find("b").text() + '|' + $(this).attr("email") + ";")
})
$("#cc").val("");
$("#carbon_copy .address_list span").each(function() {
$("#cc").val($("#cc").val() + $(this).find("b").text() + '|' + $(this).attr("email") + ";")
})

$("#bcc").val("");
$("#blind_carbon_copy .address_list span").each(function() {
$("#cc").val($("#cc").val() + $(this).find("b").text() + '|' + $(this).attr("email") + ";")
})
if ($("#to").val().indexOf("@") < 1) {
alert("请选择收件人");
$("#recever letter").focus();
return
}
editor.sync();
if(check_form("form_send")){
if (flag) {
sendForm("form_send", "{:U('send')}");
} else {
sendForm("form_send", "{:U('save_darft')}");
}
}
}

function switch_bcc() {
if ($("#bcc").attr("class").indexOf("display-none") < 0) {
$("#bcc").addClass("display-none");
$("#switch_bcc").addClass("icon-chevron-down");
$("#switch_bcc").removeClass("icon-chevron-up");
} else {
$("#bcc").removeClass("display-none");
$("#switch_bcc").addClass("icon-chevron-up");
$("#switch_bcc").removeClass("icon-chevron-down");
}
}

function popup_contact(){
winopen("{:U("popup/contact")}",730,574);
}

$(document).ready(function() {
editor_init();
})
</script>
<div class="title panel panel-default">
	<div class="panel-body">
		<h3 class="col-md-12">写邮件</h3>
	</div>
</div>
<div class="operate panel panel-default">
	<div class="panel-body">
		<div class="left">
			<a class="btn btn-default" onclick="send(true);">发送</a>
			<a class="btn btn-default" onclick="send(false);" >临时保管</a>
		</div>
	</div>
</div>
<form class="well form-horizontal" method='post' id="form_send" name="form_send" enctype="multipart/form-data">
	<input type="hidden" id="ajax" name="ajax" value="0">
	<input type="hidden" id="add_file" name="add_file">
	<input type="hidden" id="id" name="id" value="{$vo.id}">
	<input type="hidden" id="to" name="to"/>
	<input type="hidden" id="cc" name="cc"/>

	<div class="form-group">
		<label class="col-md-2 control-label" for="recever">收件人*：</label>
		<div class="col-md-10">
			<div class="input-group">
				<div id="recever" class="inputbox form-control">
					<div class="wrap" >
						<span class="address_list">{$vo.to|show_contact="edit"}</span>
						<span class="text" >
							<input class="letter" type="text"  >
						</span>
					</div>
					<div class="search dropdown ">
						<ul class="dropdown-menu"></ul>
					</div>
				</div>
				<span class="input-group-btn">
					<a class="btn btn-link" onclick="popup_contact();">
						<i class="icon-user"></i>
					</a> </span>
			</div>
		</div>
	</div>
	
	<div class="form-group">
		<div class="col-md-2 control-label">
			<label for="carbon_copy"> 抄送*：</label>
			<a onclick="switch_bcc();" ><i id="switch_bcc" class="icon-chevron-down"></i></a>
		</div>
		<div class="col-md-10">
			<div id="carbon_copy" class="inputbox">
				<div class="wrap" >
					<span class="address_list">{$vo.cc|show_contact}</span>
					<span class="text" >
						<input class="letter" type="text"  >
					</span>
				</div>
				<div class="search dropdown ">
					<ul class="dropdown-menu"></ul>
				</div>
			</div>
		</div>
	</div>

	<div id="bcc" class="form-group display-none">
		<label class="col-md-2 control-label" for="blind_carbon_copy"> 密送*： </label>
		<div class="col-md-10">
			<div id="blind_carbon_copy" class="inputbox">
				<div class="wrap" >
					<span class="address_list">{$vo.bcc|show_contact}</span>
					<span class="text" >
						<input class="letter" type="text"  >
					</span>
				</div>
				<div class="search dropdown ">
					<ul class="dropdown-menu"></ul>
				</div>
			</div>
		</div>
	</div>

	<div class="form-group">
		<label class="col-md-2 control-label" for="mail_title"> 主题*： </label>
		<div class="col-md-10">
			<input class="form-control"  type="text" name="title" id="mail_title"  check="require" msg="请输入主题" value="{$vo.name}">
		</div>
	</div>

	<div class="form-group">
		<label class="col-md-2 control-label" for="mail_title"> 附件*： </label>
		<div class="col-md-10">
			<include file="Layout:uploader" />
		</div>
	</div>

	<div class="form-group">
		<div class="col-md-12">
			<textarea id="content" name="content" class="col-md-12">{$vo.content}</textarea>
		</div>
	</div>
</form>
